<%@ page language="java" contentType="text/html;charset=UTF-8" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested"%>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack"%>

<chiptrack:checkLogon sourcePage="userDefinedFieldsForPojectSetup.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.users.User,
                 com.scalar.forecast.commons.Constants,
                 com.scalar.forecast.commons.SessionKeys"%>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY); %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML><HEAD><TITLE> User Defined Fields </TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel=stylesheet>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js">
</script>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR></HEAD>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<SCRIPT language="JavaScript">
    var fieldName = "";
    var errors1 = "";
    function openFieldValuesWindow( listName ) {
        if ( listName.trim() == '' ) {
            var pa = document.getElementById("error");
            pa.innerHTML = "<li>Please enter field name";
        } else {
            var pa = document.getElementById("error");
            pa.innerHTML = "";
            var projectId = document.userDefinedFieldsForm.projectId.value;
            listName = escape(listName).replace(/\+/g, '%2C').replace(/\"/g,'%22').replace(/\'/g, '%27');
            newWindow = window.open ('userDefinedFieldsForPojectSetup.do?action=modifyList&listName='+listName+'&projectId='+projectId,'exportToFilePopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=350 height=350,resizable=no,left=375,top=180');
            newWindow.focus();
        }
    }
    function closeWindow( form ) {
        form.action.value = "edit";
        window.opener.enableFields();
        form['projectSetup.projectID'].value = document.userDefinedFieldsForm.projectId.value;
        form.submit();
        window.close();
    }
    function checkUserDefinedFieldNames() {
        for( var i = 0; i < 20; i++ ) {
            fieldName = (document.userDefinedFieldsForm.elements[i].value).trim().toUpperCase()
            if ( fieldName == 'CUSTOMER NAME' || fieldName == 'PROJECT NAME' || fieldName == 'PROJECT STATUS' ) {
                errors1 = "<li> Field names should not be Customer Name/Project Name/Project Status"
                break;
            }
        }
        xyz:
        for ( var i = 0; i < 19; i++ ) {
            for ( var j = i+1; j < 20; j++ ) {
                if ( ( document.userDefinedFieldsForm.elements[i].value ).trim() != "" && ( document.userDefinedFieldsForm.elements[j].value ).trim() != "" &&
                     ( document.userDefinedFieldsForm.elements[i].value ).trim() == ( document.userDefinedFieldsForm.elements[j].value ).trim()
                    ) {
                    errors1 = errors1+"<br><li> User Defined Fields should not be repeated"
                    break xyz ;
                }
            }
        }
    }
    function save() {
        errors1="";
        checkUserDefinedFieldNames();
        if ( errors1 == "" ) {
            document.userDefinedFieldsForm.action.value="save";
            document.userDefinedFieldsForm.submit();
        }
        else{
            var pa = document.getElementById("errorsId");
            pa.innerHTML = "";
            pa = document.getElementById("infoId");
            pa.innerHTML = "";
            pa = document.getElementById("error");
            pa.innerHTML = errors1;
        }
    }
</SCRIPT>

<html:form name="userDefinedFieldsForm" method="post"  action="/userDefinedFieldsForPojectSetup.do" scope="request" type="com.scalar.forecast.projectSetup.forms.UserDefinedFieldsForm" >

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
  <TBODY>
  <TR>
    <TD bgcolor="#ffffff">
        <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">

        <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
        <BR>
<!-- from here your body starts -->
        <TABLE border="0">
                <% if ( !user1.isActionAllowed ( Functionality.PROJECT_SETUP, User.USER_ACTION_MODIFY ) ) { %>
                <tr><td colspan=6 align='left'><font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></td></tr> <% } %>
                <TR>
                    <TD colspan="6" bgColor="#993333"   height="16"><FONT class="NArialL" style="color:#ffffff">&nbsp;User Defined Fields Entry</FONT></TD>
                </TR>
                <TR><TD colspan =6 class="NArialL" id="errorsId"><chiptrack:errors styleClass="NArialL" /></TD></TR>
                <TR><TD colspan =6 class="NArialL" id="infoId"><chiptrack:info styleClass="NArialL" /></TD></TR>
                <TR><TD colspan="6" align="left" class='NArialL'><font styleClass="NArialL" id="error" color="FF0000"  />&nbsp;</font></TD></TR>
                <TR>
                    <TD class="NArialL"> List1:</TD>
                    <TD ><html:text property="list1" styleClass="txfield" maxlength="25" /> </TD>
                    <TD><a href="javascript:openFieldValuesWindow( document.userDefinedFieldsForm.list1.value )" ><img src="<%=chipTracContext%>/jsp/includes/images/arrow.gif" border="0" height="12" width="18" onmouseover="window.status='Click here to add values to List box';return true" title="Click here to add values to List box" onmouseout="window.status='';return true"></a></TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field1:</TD>
                    <TD><html:text property="text1" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> List2:</TD>
                    <TD><html:text property="list2" styleClass="txfield" maxlength="25" /></TD>
                    <TD><a href="javascript:openFieldValuesWindow(userDefinedFieldsForm.list2.value)"><img src="<%=chipTracContext%>/jsp/includes/images/arrow.gif" border="0" height="12" width="18" onmouseover="window.status='Click here to add values to List box';return true" title="Click here to add values to List box" onmouseout="window.status='';return true"></TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field2:</TD>
                    <TD><html:text property="text2" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> List3:</TD>
                    <TD><html:text property="list3" styleClass="txfield" maxlength="25"  /></TD>
                    <TD><a href="javascript:openFieldValuesWindow(userDefinedFieldsForm.list3.value)"><img src="<%=chipTracContext%>/jsp/includes/images/arrow.gif" border='0' height='12' width='18' onmouseover="window.status='Click here to add values to List box';return true" title="Click here to add values to List box" onmouseout="window.status='';return true"></TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field3:</TD>
                    <TD><html:text property="text3" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> List4:</TD>
                    <TD ><html:text property="list4" styleClass="txfield" maxlength="25" /> </TD>
                    <TD><a href="javascript:openFieldValuesWindow( document.userDefinedFieldsForm.list4.value )" ><img src="<%=chipTracContext%>/jsp/includes/images/arrow.gif" border="0" height="12" width="18" onmouseover="window.status='Click here to add values to List box';return true" title="Click here to add values to List box" onmouseout="window.status='';return true"></a></TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field4:</TD>
                    <TD><html:text property="text4" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> List5:</TD>
                    <TD><html:text property="list5" styleClass="txfield" maxlength="25" /></TD>
                    <TD><a href="javascript:openFieldValuesWindow(userDefinedFieldsForm.list5.value)"><img src="<%=chipTracContext%>/jsp/includes/images/arrow.gif" border="0" height="12" width="18" onmouseover="window.status='Click here to add values to List box';return true" title="Click here to add values to List box" onmouseout="window.status='';return true"></TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field5:</TD>
                    <TD><html:text property="text5" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> List6:</TD>
                    <TD><html:text property="list6" styleClass="txfield" maxlength="25"  /></TD>
                    <TD><a href="javascript:openFieldValuesWindow(userDefinedFieldsForm.list6.value)"><img src="<%=chipTracContext%>/jsp/includes/images/arrow.gif" border='0' height='12' width='18' onmouseover="window.status='Click here to add values to List box';return true" title="Click here to add values to List box" onmouseout="window.status='';return true"></TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field6:</TD>
                    <TD><html:text property="text6" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> Date Field1:</TD>
                    <TD><html:text property="date1" styleClass="txfield" maxlength="25" /></TD>
                    <TD>&nbsp;</TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field7:</TD>
                    <TD><html:text property="text7" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> Date Field2:</TD>
                    <TD><html:text property="date2" styleClass="txfield" maxlength="25" /></TD>
                    <TD>&nbsp;</TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field8:</TD>
                    <TD><html:text property="text8" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> Date Field3:</TD>
                    <TD><html:text property="date3" styleClass="txfield" maxlength="25" /></TD>
                    <TD>&nbsp;</TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field9:</TD>
                    <TD><html:text property="text9" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR>
                    <TD class="NArialL"> Date Field4:</TD>
                    <TD><html:text property="date4" styleClass="txfield" maxlength="25" /></TD>
                    <TD>&nbsp;</TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL">Text Field10:</TD>
                    <TD><html:text property="text10" styleClass="txfield" maxlength="25" /></TD>
                </TR>
                <TR> <TD>&nbsp;</TD> </TR>
                <TR>
                    <TD colspan="6" align="center">
                    <chiptrack:restrictedLink functionality='<%=Functionality.PROJECT_SETUP%>' action='<%=User.USER_ACTION_MODIFY%>' href="javascript:save();" onmouseover="window.status='Click to Save User Defined Fields';return true" onmouseout="window.status='';return true">
                       <IMG onmouseover="window.status='Click to Save User Defined Fields';return true" title="Click here to Save User Defined Fields" onmouseout="window.status='';return true" height=17  src="<%=chipTracContext%>/jsp/includes/images/save.gif" width=53  border=0>
                    </chiptrack:restrictedLink>&nbsp;&nbsp;&nbsp;&nbsp;
                       <a href="javascript:document.userDefinedFieldsForm.reset();"><IMG onmouseover="window.status='Click here to Reset';return true" title="Click here to Reset" onmouseout="window.status='';return true" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" border=0></a>&nbsp;&nbsp;&nbsp;&nbsp;
                       <%--a href="javascript:closeWindow()"><IMG onmouseover="window.status='Click here to Cancel';return true" title="Click here to Cancel " src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" border=0></a --%>
                    </TD>
                </TR>
                <TR> <TD colspan="6" align="center">
                    <a href="javascript:closeWindow( window.opener.document.projectSetupForm );"  onMouseOver="window.status='Click here to close this window';return true" title='Click here to close this window'><font class='NArialL'><b>[Close this window]</b></font></a>
                </TD> </TR>

        </TABLE>
        <input type="hidden" name="action" value="">
        <input type="hidden" name="projectId" value="<%=request.getParameter("projectId")%>">
        </html:form>
    </TD>
<!-- till here -->
  </TR>
  </TBODY>
</TABLE>
</BODY>
</HTML>

